<?php foreach($data['flats'] as $k1=>$v1): ?>
  <div class='main-site-content-appartements-content-text-flat'>              
      <div style='display: none' class='flat-ref'><?php echo $v1->cha_id; ?></div>
      <div class="main-site-content-appartements-content-text-flat-preview">
        <img src="<?php echo $data['baseurl']; ?>global/img/appartements/pictures/thumbnails/<?php   echo $data['pictures'][$v1->cha_id]['pictures'][0] ?>" alt='<?php  echo $data['pictures'][$v1->cha_id]['alt'] ?>'>
        <div class='main-site-content-appartements-content-tex-flat-content'>
          <div class='main-site-content-appartements-content-tex-flat-content-line'><span class='bold'>Emplacement </span>: <?php echo $v1->FrbFlatImmeuble->imm_adr; ?> à Marseille</div>
          <div class='main-site-content-appartements-content-tex-flat-content-line'><span class='bold'>Surface</span> : <?php echo $v1->cha_surf; ?> m²</div>
          <div class='main-site-content-appartements-content-tex-flat-content-line'> 
            <span class='bold'>Loyer à l'année</span> : <?php echo $v1->cha_loy_low; ?> €/mois 
            <span class='bold'> Pleine saison </span>: <a href='<?php echo $data['baseurl']; ?>contact' class='frb-popup-shadow'>nous contacter</a></div>
          <div class='main-site-content-appartements-content-tex-flat-content-line'><span class='bold'>Description : </span><?php echo $v1->cha_det; ?></div>
        </div>
        
    </div>
    <div class="show-detail">+ d'infos</div>
    <div class="main-site-content-appartements-content-text-flat-images"></div>
  </div>
<?php endforeach; ?>
<script type="text/javascript">

var oldToggle=null;

$('.show-detail').click(function(){
  t = $(this).parent(".main-site-content-appartements-content-text-flat");
  var flat = t.children(".flat-ref").html();
  if(t.css('height') == '100px'){
    t.prevAll('.main-site-content-appartements-content-text-flat').hide('normal');
    t.animate({height : '300px'});
    if(oldToggle != null)
      oldToggle.animate({height : '100px'});
    oldToggle = t;
    $.ajax({
      url: '<?php echo $data['baseurl']; ?>getFlatPictures?flat='+flat,
      type: 'GET',
      cache: false,
      success: function(html){
        t.children(".main-site-content-appartements-content-text-flat-images").html(html);
      }
    });
  }else if(t.css('height') == '300px'){
    oldToggle = null;
    t.animate({height : '100px'});
    $('.main-site-content-appartements-content-text-flat').show('normal');
  }
});
</script>